package scalaLearning.part3


abstract class GrandFather {
  def say()={
    println("GrandFater nice")
  }
}
class Father extends GrandFather{
  override def say(): Unit = {
    println("Father nice")
  }
}
class Child extends GrandFather{
  override def say(): Unit = {
    println("Child nice")
  }
}

object ManyType{
  def sayHi(df:GrandFather) = {
    df.say()
  }
  def main(args: Array[String]): Unit = {
    val df:GrandFather = new Father
    sayHi(df)  //父类引用指向子类对象 Father nice
    sayHi(new Child)   //祖父类指向孙类对对象 Child nice
  }
}
